<%@ page import="tools.TimeTools" %>
<%@ page import="java.sql.Timestamp" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%--
  Created by IntelliJ IDEA.
  User: 高金磊
  Date: 2021/5/16
  Time: 8:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title></title>
<link rel="icon" href="<%=basePath%>favicon.ico" type="image/ico">
    <link href="<%=basePath%>css/style.css" rel="stylesheet">
    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">
    <link href="<%=basePath%>css/theme.css" rel="stylesheet">
    <link href="<%=basePath%>css/fonts.css" rel="stylesheet">
    <script src="<%=basePath%>js/jquery.min.js"></script>
    <script src="<%=basePath%>js/bootstrap.js"></script>
    <script src="<%=basePath%>js/jquery.cookie.js"></script>
    <script src="<%=basePath%>js/framework.js"></script>
</head>
<body>


<s:form action="Setting_info" method="GET">
<div class="col-md-12">
    <div class="card">
        <%--<div class="card-header"><h4>系统管理</h4></div>--%>
        <div class="card-body">
            <div>
            <span style="color: red;font-size: 14px"><s:actionerror/></span>
            <span style="color: green;font-size: 14px"><s:actionmessage/></span>
            </div>
            <ul id="myTabs" class="nav nav-tabs" role="tablist">
                <li class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab"><strong>系统信息</strong></a></li>
                <li><a href="#profile" role="tab" id="profile-tab" data-toggle="tab"><strong>系统设置</strong></a></li>
            </ul>
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade active in" id="home">
                    <div class="container-fluid" style="margin-bottom:90px;">
                        <h3>系统基本信息<small>更新于<%=TimeTools.timeStamp2Date(new Timestamp(System.currentTimeMillis()), "yyyy-MM-dd HH:mm")%></small></h3>
                        <div class="row" style="margin-top:15px;">
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">用户数量</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.UserNum" /> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">书籍数量</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.BookNum" /> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">系统日志</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.SysLog" /> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">用户日志</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.UserLog" /> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">订单总数</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.LoanrecordSize" /> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">订单日志</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.orderLog" /> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">评论数量</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.CommentSize"/> </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">数据库存储空间占用</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.databaseSize"/>MB </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">缓存空间占用</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.cacheSize"/>MB </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-3 col-lg-2">
                                <div class="card bg-primary">
                                    <div class="card-body clearfix">
                                        <div align="center">
                                            <p class="h6 text-white m-t-0">系统使用总空间</p>
                                            <p class="h3 text-white m-b-0"><s:property value="#request.AllSize"/>MB </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <br>
                        </div>

                        <div class="col-md-12">
                            <div class="card">
                                <div class="card-header"><h4>管理员操作日志</h4></div>
                                <div class="card-body">

                                    <ul class="nav nav-tabs nav-justified">
                                        <li class="active">
                                            <a data-toggle="tab" href="#home-basic">
                                                用户相关
                                            </a>
                                        </li>
                                        <li class="nav-item">
                                            <a data-toggle="tab" href="#profile-basic">图书相关</a>
                                        </li>
                                        <li class="nav-item">
                                            <a data-toggle="tab" href="#settings-basic"> 系统相关</a>
                                        </li>
                                    </ul>
                                    <div class="tab-content" style="overflow: auto;max-height: 2000px">
                                        <div class="tab-pane fade active in" id="home-basic">
                                            <table class="table table-condensed">
                                                <thead>
                                                <tr>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <s:iterator value="#request.userLogs" var="data">
                                                    <tr>
                                                        <td><s:property value="#data"/> </td>
                                                    </tr>
                                                </s:iterator>

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="tab-pane fade" id="profile-basic">
                                            <table class="table table-condensed">
                                                <thead>
                                                <tr>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <s:iterator value="#request.bookLogs" var="data">
                                                    <tr>
                                                        <td><s:property value="#data"/> </td>
                                                    </tr>
                                                </s:iterator>

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="tab-pane fade" id="settings-basic">
                                            <table class="table table-condensed">
                                                <thead>
                                                <tr>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <s:iterator value="#request.sysLogs" var="data">
                                                    <tr>
                                                        <td><s:property value="#data"/> </td>
                                                    </tr>
                                                </s:iterator>

                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                </div>
                </div>

                <div class="tab-pane fade" id="profile">
                    <div class="card-header"><h4>配置修改</h4></div>
                    <div class="col-md-6">
                        <div class="card">
                            <div class="card-body">
                                <h5 style="color: #0dcaf0">订单设置</h5>
                                    <div class="form-group">
                                        <label >借书最少天数</label>
                                        <input class="form-control" type="number" name="LoanBook_Min_day" value=<s:property value="#request.LoanBook_Min_day"/>>
                                    </div>
                                <div class="form-group">
                                        <label >借书最多天数</label>
                                        <input class="form-control" type="number" name="LoanBook_Max_day" value=<s:property value="#request.LoanBook_Max_day"/>>
                                    </div>
                                    <div class="form-group">
                                        <label >每人最多借阅书本数量</label>
                                        <input class="form-control" type="number" name="LoanBookNum_Max_Num" value=<s:property value="#request.LoanBook_Max_Num"/>>
                                    </div>
                                <h5 style="color: #0dcaf0">缓存设置</h5>
                                    <div class="form-group">
                                        <label >缓存检查最小时间间隔(分钟)<small style="font-size: 10px">自动检测缓存大小的时间间隔,不一定发生清理</small></label>
                                        <input  class="form-control" type="number" name="SYS_min_cache_time" value=<s:property value="#request.SYS_min_cache_time" />>
                                    </div>
                                    <div class="form-group">
                                        <label >缓存文件最大有效时间(分钟)<small>当缓存文件在这个时间内没有发生使用时将会在下次检查时清理</small></label>
                                        <input class="form-control" type="number" name="SYS_cache_Max_time" value=<s:property value="#request.SYS_cache_Max_time" />>
                                    </div>
                                    <div class="form-group">
                                        <label >缓存最大值(MB)</label>
                                        <input class="form-control" type="number" name="SYS_cache_MaxSize" value=<s:property value="#request.SYS_cache_MaxSize" />>
                                    </div>
                                    <div class="form-group">
                                       <label>缓存模式</label>
                                        <select class="form-control" name="SYS_cache_Model"  >
                                            <option value="1" <s:if test="#request.SYS_cache_Model==1">selected</s:if>>仅数据库</option>
                                            <option value="2" <s:if test="#request.SYS_cache_Model==2">selected</s:if>>本地数据优先(推荐)</option>
                                            <option value="3" <s:if test="#request.SYS_cache_Model==3">selected</s:if>>仅本地数据</option>
                                        </select><br>
                                       <small style="font-size: 11px">
                                        仅数据库:文件都来自数据库,磁盘缓存无效(能尽快获得书籍等信息的改变,建议在图书信息变更时采用)<br>
                                        本地数据优先：在缓存文件最大有效时间内本地为主（并自动更新本地缓存数据）<br>
                                        仅本地数据：本地数据优先且使用缓存时不会主动更新缓存数据。<br>
                                       </small>
                                    </div>

                                    <div class="form-group">
                                        <button class="btn btn-primary" type="submit"  formaction="Setting_update">提交修改</button>
                                    </div>
                                <div class="form-group">
                                    <label >当前缓存大小<strong><s:property value="#request.cacheSize"/></strong>MB</label>
                                    <div class="progress">
                                        <div class="progress-bar" role="progressbar" style="width: <s:property value="#request.cacheSize*100/#request.SYS_cache_MaxSize"/>%;" aria-valuemin="0" aria-valuemax="100">
                                           <span style="color: #000000"><s:property value="#request.cacheSize*100/#request.SYS_cache_MaxSize"/>%</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <input id="myButton1" data-loading-text="正在清理....." class="btn btn-warning" type="submit" value="立即清理缓存" formaction="Setting_cache_clear"/><br>
                                    缓存区清理:<s:property value="#request.clear"/>KB<br>
                                </div>
                            </div>
                            <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
                            </div>

                    </div>
                    <div class="col-md-6">
                        <div class="card">
                            <div class="card-body">
                                <h5 style="color: #0dcaf0">数据库状态</h5>
                                <div class="form-group">
                                    当前数据库大小:<s:property value="#request.databaseSize"/>MB
                                </div>
                                <h5 style="color: rgba(13,202,240,0.47)">日志数据</h5>
                                <div class="form-group">
                                   用户日志数量:<s:property value="#request.UserLog"/>
                                </div>

                                <div class="form-group">
                                    订单日志数量:<s:property value="#request.orderLog"/>
                                </div>
                                <div class="form-group">
                                    系统日志数量:<s:property value="#request.SysLog"/>
                                </div>
                                <div class="form-group">
                                    <button type="submit" formaction="Setting_database_clear" id="myButton" data-loading-text="正在维护....." class="btn btn-primary">
                                        维护数据库
                                    </button>
                                </div>
                                    <ul>
                                        <li style="font-size: 10px">
                                            清理30天前的用户日志和180天前的系统日志。（保留10+用户登录日志）
                                        </li>
                                        <li style="font-size: 10px">
                                            对已经下架的图书和已删除用户的订单,评论,日志进行删除
                                        </li>
                                    </ul>
                            </div>
                        </div>
                    </div>
                    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
                </div>
            </div>
            <div hidden="hidden">


                    <%--借书最多天数:<input type="number" name="LoanBook_Max_Num" value=<s:property value="#request.LoanBook_Max_Num"/>><br>--%>
                    <%--借书最少天数:<input type="number" name="LoanBook_Min_day" value=<s:property value="#request.LoanBook_Min_day" />><br>--%>
                    <%--缓存检查最小时间间隔:<input type="number" name="SYS_min_cache_time" value=<s:property value="#request.SYS_min_cache_time" />>分钟<br>--%>
                    <%--自动检测缓存大小的时间间隔,不一定发生清理<br>--%>
                    <%--缓存文件最大有效时间:<input type="number" name="SYS_cache_Max_time" value=<s:property value="#request.SYS_cache_Max_time" />>分钟<br>--%>
                    <%--当缓存文件在这个时间内没有发生使用时将会在下次检查时清理<br>--%>
                    <%--缓存最大值:<input type="number" name="SYS_cache_MaxSize" value=<s:property value="#request.SYS_cache_MaxSize" />>MB<br>--%>
                    <%--当缓存区大于该值时强行清理<br>--%>
                    <%--缓存模式--%>
                    <%--<select name="SYS_cache_Model"  >--%>
                        <%--<option value="1" <s:if test="#request.SYS_cache_Model==1">selected</s:if>>仅数据库</option>--%>
                        <%--<option value="2" <s:if test="#request.SYS_cache_Model==2">selected</s:if>>本地数据优先</option>--%>
                        <%--<option value="3" <s:if test="#request.SYS_cache_Model==3">selected</s:if>>仅本地数据</option>--%>
                    <%--</select><br>--%>
                    <%--仅数据库:文件都来自数据库,磁盘缓存无效(能尽快获得书籍等信息的改变,建议在图书信息变更时采用)<br>--%>
                    <%--本地数据优先：在缓存文件最大有效时间内本地为主（并自动更新本地缓存数据）<br>--%>
                    <%--仅本地数据：本地数据优先且不会主动更新缓存数据。<br>--%>
                    <%--<input type="submit" value="提交修改" formaction="Setting_update"><br>--%>

                    <%--当前缓存大小:<s:property value="#request.cacheSize"/>KB<br>--%>



                    <%--<input type="submit" value="立即清理缓存" formaction="Setting_cache_clear"/><br>--%>
                    <%--缓存区清理:<s:property value="#request.clear"/>KB<br>--%>
                </div>
            <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        </div>

        </div>
    </div>



</s:form>
<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/bootstrap.js"></script>
<script>
    // 按钮示例
    $('#myButton').on('click', function () {
        var $btn = $(this).button('loading');
        // setTimeout(function() {
        //     $btn.button("reset")
        // }, 3e3)
    });
    $('#myButton1').on('click', function () {
        var $btn = $(this).button('loading');
        setTimeout(function() {
            $btn.button("reset")
        }, 3e3)
    });
</script>
</body>


</html>
